// 向 wx 对象上扩展对象

(function(e) {
  function n(e, n) {
    for (var t = 0; t < n.length; ++t)
      if (e.indexOf(n[t]) > -1) return !0;
    return !1;
  }

  if (/msie 6/i.test(navigator.userAgent)) return void(window.location = "/cgi-bin/readtemplate?t=err/noie6_tmpl");

  window.console || (window.console = {
    log: function() {},
    error: function() {},
    info: function() {}
  }),

  // 如果之前没有 wx 对象，这里置为空对象
  e.wx = e.wx || {},

  // 扩展模板编译方法（要求先有 template 对象）
  wx.T = function(e, n) {
    return template.compile(e)(n);
  },

  wx.url = function(e) {
    if (e.startsWith("javasript:")) return e;
    var n = wx.data.param;
    return -1 != e.indexOf("?") ? e + n : e + "?1=1" + n;
  },

  wx.getUrl = function(e) {
    var n = (window.location + "&").match(new RegExp("(?:\\?|\\&)" + e + "=(.*?)\\&"));
    return n && n[1] ? String(n[1]).html(!0) : void 0;
  },

  $.fn.setClass = function(e) {
    this.attr("class", e);
  },

  $("img").error(function(e) {
    var n = e && e.target && e.target.src || "";
    if (BJ_REPORT)
      if (BJ_REPORT.monitor && "function" == typeof BJ_REPORT.monitor) BJ_REPORT && BJ_REPORT.monitor(1, "[img-src]" + n, 110);
      else {
        var t = "[no_monitor]BJ_REPORT:" + n;
        for (var o in BJ_REPORT) t += o + "|";
        var r = new Image;
        r.src = "https://badjs.weixinbridge.com/badjs?id=110&msg=" + encodeURIComponent(t) + "&uin=" + (wx && wx.uin) + "&from=" + encodeURIComponent(location.href) + "&level=4";
      }
  }),

  wx.jslog = function(e, n, t) {
    t = t || 3;
    var o = new Image,
      r = [];
    n && jQuery.each(["message", "stack", "lineNumber"], function(e, t) {
      r.push(t + ":" + (n[t] || ""));
    }), r.push("level:2"), o.src = "https://badjs.weixinbridge.com/badjs?id=5&uin=" + wx.data.uin + "&msg=" + encodeURIComponent(r.join(";").replace(/\s/g, " ")) + "&from=" + encodeURIComponent(location.href) + "&_t=" + +new Date;
    var s = new Image;
    s.src = "/backend/material/jslog?id=" + t + "&content=jslog&level=error", console && console.error && n && console.error(n);
  },

  setTimeout(function() {
    seajs.use("biz_web/lib/store.js", function(e) {
      var n = $("#logout");
      n.length > 0 && n.click(function() {
        function n() {
          var n = e.get(o);
          return new Date - n > 864e5;
        }
        e.remove("hasNotice"), e.remove("templateClassStatus"), e.remove("templateClassStatusTime");
        var t = "__draft__" + wx.data.uin,
          o = "__draft__time__" + wx.data.uin;
        n() && (e.remove(t), e.remove(o));
      });
    });
  }, 5e3),

  wx.resPath = "mp.weixin.qq.com" == location.hostname ? "https://res.wx.qq.com" : "",

  jQuery(function() {
    var e = ['<div class="scale_tips" id="zoom_tips" style="display:none;">', '<div class="scale_tips_inner">', '<i class="icon_scale_tips"></i>', '<p class="scale_tips_content"><span id="zoom_msg"></span><a href="javascript:;" id="zoom_prompt">不再提示</a></p>', "</div>", "</div>"].join("\n");
    jQuery("body").append(e);
    var n = '<object type="application/x-shockwave-flash" data="{swfpath}" width="10" height="10" id="{id}">{param}</object>',
      t = {
        swfpath: wx.path.zoom,
        id: "ZoomFlash",
        param: ""
      },
      o = {
        movie: t.swfpath,
        allowscriptaccess: "always",
        wmode: "transparent",
        scale: "noScale"
      };
    jQuery.each(o, function(e, n) {
        t.param += '<param name="' + e + '" value="' + n + '">';
      }), $('<div style="position: absolute; right: 0px; bottom: 0px; visibility: visible;"></div>').html(n && n.format(t)).appendTo("body"),
      seajs.use("biz_web/lib/store.js", function(e) {
        jQuery(window).on("load resize", function() {
          if (e && !e.get("__zoom_tips__") && document.getElementById("ZoomFlash")) {
            var n = document.getElementById("ZoomFlash").height,
              t = n,
              o = 1;
            try {
              t = document.getElementById("ZoomFlash").getFlashStageRect().height, o = ~window.navigator.userAgent.toLowerCase().indexOf("msie") && screen.deviceXDPI && screen.logicalXDPI ? screen.deviceXDPI / screen.logicalXDPI : t / n, .9 > o ? (jQuery("#zoom_msg").text("您的浏览器目前处于缩小状态，会导致公众平台网页显示不正常，您可以键盘按“ctrl+数字0”组合键恢复初始状态。"), jQuery("#zoom_tips").show(), jQuery("body").addClass("scaled")) : o > 1.1 ? (jQuery("#zoom_msg").text("您的浏览器目前处于放大状态，会导致公众平台网页显示不正常，您可以键盘按“ctrl+数字0”组合键恢复初始状态。"), jQuery("#zoom_tips").show(), jQuery("body").addClass("scaled")) : (jQuery("#zoom_tips").hide(), jQuery("body").removeClass("scaled"));
            } catch (r) {}
          }
        });
      }), jQuery(window).on("keyup", function(e) {
        e.ctrlKey && (96 == e.keyCode || 48 == e.keyCode) && (jQuery("#zoom_tips").hide(), jQuery("body").removeClass("scaled"));
      }), jQuery("#zoom_prompt").on("click", function() {
        seajs.use("biz_web/lib/store.js", function(e) {
          e.set("__zoom_tips__", !0);
        }), jQuery("#zoom_tips").hide(), jQuery("body").removeClass("scaled");
      }), "undefined" != typeof _new_comment_num && _new_comment_num > 0 && (_new_comment_num = _new_comment_num > 1e3 ? "999+" : _new_comment_num, _new_comment_num > 0 && !jQuery(".menu_item>a[data-id=10033]").parent().hasClass("selected") && jQuery(".menu_item>a[data-id=10033]").append('<span class="icon_dot_notices"><span class="icon_dot_notices_left"></span><span class="icon_dot_notices_right"></span>' + _new_comment_num + "</span>"));
  }),

  jQuery("#menuBar").find("dd>a").click(function() {
    $(this).find(".new").length > 0 && jQuery.ajax({
      url: "/misc/navoperation",
      data: {
        action: "click",
        id: $(this).data("id"),
        token: wx.data.t
      },
      type: "post"
    });
  }),

  function() {
    try {
      var e = jQuery(window).height();
      750 > e && jQuery(document.body).addClass("screen_small");
    } catch (n) {}
  }();

  var t = ["biz_common/utils/monitor.js", "biz_common/utils/huatuo.js"];

  seajs.on("request", function(e) {
    if (0 != location.host.indexOf("dev") && !/[a-f0-9]{6}\.(js|css)$/.test(e.requestUri) && !n(e.requestUri, t)) {
      var e = {
          res: e.requestUri,
          page: location.pathname + "?" + location.search
        },
        o = encodeURIComponent("res[{res}]; page[{page}]".format(e));
      (new Image).src = wx.url("/backend/material/jslog?content=" + o + "&id=59&level=error");
    }
  }),

  wx.getBanInfo = function(e) {
    for (var n = wx.ban_func_list, t = 0; t < n.length; t++)
      if (n[t].func_id == e) return n[t];
    return null;
  };
})(window);;